import java.util.LinkedList;
import java.util.Queue;
import java.util.Stack;

public class prog {
    public static void main(String[] args) {
        Queue<Integer> queue= new LinkedList<>();

    }
}
class Solution {
    public boolean isPowerOfThree(int n) {
        while(n!=0&&n%3==0){
            n/=3;
        }
        return n==1;
    }
}




class MinStack {
    /** initialize your data structure here. */
    private Stack<Integer> stack;
    private Stack<Integer> minstack;
    public MinStack() {
        stack=new Stack<Integer>();
        minstack=new Stack<Integer>();
    }

    public void push(int val) {
        stack.push(val);
        if(minstack.empty()){
            minstack.push(val);
        }else{
            if(val<=minstack.peek()){
                minstack.push(val);
            }
        }
    }

    public void pop() {
        int val=stack.pop();
        if(!minstack.empty()){
            if(val==minstack.peek()){
                minstack.pop();
            }
        }
    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return minstack.peek();
    }
}

/**
 * Your MinStack object will be instantiated and called as such:
 * MinStack obj = new MinStack();
 * obj.push(val);
 * obj.pop();
 * int param_3 = obj.top();
 * int param_4 = obj.getMin();
 */



